package com.ghh.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.ghh.dao.CompanyDao;

import com.ghh.entity.PageResult;
import com.ghh.entity.QueryPageBean;
import com.ghh.pojo.Company;
import com.ghh.service.CompanyService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

@Service
public class CompanyServiceImpl implements CompanyService {

    @Autowired
    private CompanyDao companyDao;

    @Override
    public List<Company> findAll() {
        return companyDao.findAll();
    }

    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        Page<Company> page = companyDao.findPage(queryPageBean.getQueryString());
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public void addAddress(Company company) {
        companyDao.addAddress(company);
    }

    @Override
    public void delete(Integer id) {
        companyDao.delete(id);
    }

    @Override
    public List<Map<String,Object>> findAllCompany() {
       return companyDao.findAllCompany();
    }
}
